<template>
  <div class="WorkingSchedule" v-loading="loading">
    <el-form ref="form" :model="form" label-position="top" class="myform">
      <div>
        <el-form-item label="组合码" class="myform-item">
          <el-input
            v-model="form.skuCode"
            placeholder="请输入组合码"
            @keyup.enter.native="onSearch"
            clearable
          ></el-input>
        </el-form-item>
        <el-form-item label="套装名称" class="myform-item">
          <el-input
            v-model="form.skuName"
            placeholder="请输入套装名称"
            @keyup.enter.native="onSearch"
            clearable
          ></el-input>
        </el-form-item>
        <el-form-item label="款号" class="myform-item">
          <el-input
            v-model="form.combinationProductCodes"
            placeholder="请输入款号"
            @keyup.enter.native="onSearch"
            clearable
          ></el-input>
        </el-form-item>
        <el-form-item label="SKU" class="myform-item">
          <el-input
            v-model="form.combinationSkuCodes"
            placeholder="请输入SKU"
            @keyup.enter.native="onSearch"
            clearable
          ></el-input>
        </el-form-item>
      </div>
      <div>
        <el-form-item style="margin-top: 50px">
          <el-button type="primary" @click="onSearch">查询</el-button>
        </el-form-item>
      </div>
    </el-form>
    <div>
      最后更新日期：{{ savetime }}
    </div>
    <el-table
      :data="tableData"
      style="width: 100%"
      :height="browserHeight - 290"
      size="mini"
      border
      :span-method="arraySpanMethod"
    >
      <el-table-column label="套装名称" align="center" prop="skuName">
      </el-table-column>
      <el-table-column label="组合码" align="center" prop="skuCode">
      </el-table-column>
      <el-table-column label="组合库存数量(现货)" align="center" prop="xianhu">
        <template slot-scope="{ row }">
          <div style="color: #71d5a1; font-size: 16px; font-weight: 600">
            {{ row.xianhu }}
          </div>
        </template>
      </el-table-column>
      <el-table-column label="组合库存数量(预售)" align="center" prop="yushou">
        <template slot-scope="{ row }">
          <div style="color: #ffca42; font-size: 16px; font-weight: 600">
            {{ row.yushou }}
          </div>
        </template>
      </el-table-column>
      <el-table-column
        label="预计到货日期"
        align="center"
        prop="arrivaldate"
        width="180"
      >
        <template scope="{row}" class="tableTwo">
          <el-table
            :data="row.details"
            style="width: 100%"
            size="mini"
            :show-header="false"
          >
            <el-table-column
              label="预计到货日期"
              align="center"
              prop="arrivaldate"
            >
            </el-table-column>
            <el-table-column label="款号" align="center" prop="productCode">
            </el-table-column>
            <el-table-column label="款名" align="center" prop="productName">
            </el-table-column>
            <el-table-column label="SKU" align="center" prop="skuCode">
            </el-table-column>
            <el-table-column label="部件" align="center" prop="a_parts">
            </el-table-column>
            <el-table-column label="SKU库存数量(预售)" align="center" prop="yushou">
              <template slot-scope="{ row }">
                {{ row.yushou }}
              </template>
            </el-table-column>
            <el-table-column
              label="SKU库存数量(现货)"
              align="center"
              prop="xianhu"
              width="178"
            >
              <template slot-scope="{ row }">
                {{ row.xianhu }}
              </template>
            </el-table-column>
          </el-table>
        </template>
      </el-table-column>
      <el-table-column label="款号" align="center" width="180">
      </el-table-column>
      <el-table-column label="款名" align="center" width="180">
      </el-table-column>
      <el-table-column label="SKU" align="center" width="180">
      </el-table-column>
      <el-table-column label="部件" align="center" width="180">
      </el-table-column>
      <el-table-column label="SKU库存数量(预售)" align="center" width="180">
      </el-table-column>
      <el-table-column label="SKU库存数量(现货)" align="center" width="179">
      </el-table-column>

      <!-- <el-table-column label="" align="center"> </el-table-column> -->
    </el-table>
    <paginationJy
      :form="form"
      :total="total"
      @paginationPostOrderTaskList="postAdminOperateGetItemsQueryData"
    />
  </div>
</template>

<script>
import { postAdminOperateGetItemsQueryData } from "@/api";
import paginationJy from "@/components/paginationJy.vue";
export default {
  components: { paginationJy },
  data() {
    return {
      loading: false,
      dialogVisible: false,
      savetime: "",
      browserHeight: "",
      form: {
        skuCode: "",
        skuName: "",
        combinationProductCodes: "",
        combinationSkuCodes: "",
        page: 1,
        pageSize: 10,
      },
      tableData: [],
      total: 1,
    };
  },
  activated() {
    this.browserHeight =
      window.innerHeight ||
      document.documentElement.clientHeight ||
      document.body.clientHeight;
    let form = this.form;
    this.postAdminOperateGetItemsQueryData(form);
  },
  methods: {
    arraySpanMethod({ row, column, rowIndex, columnIndex }) {
      console.log("row", row);
      console.log("column", column);
      if (column.label == "预计到货日期") {
        return {
          rowspan: 1,
          colspan: 7,
        };
      } else {
        return {
          rowspan: 1,
          colspan: 1,
        };
      }
    },
    // 采购列表
    async postAdminOperateGetItemsQueryData(data) {
      this.loading = true;
      this.form = data;
      postAdminOperateGetItemsQueryData(data)
        .then((res) => {
          this.loading = false;
          console.log("采购列表", res);
          this.savetime = res.savetime;
          this.tableData = res.data;
          this.total = Number(res.total);
        })
        .catch((err) => {
          this.loading = false;
        });
    },
    // 搜索
    onSearch() {
      this.form.page = 1;
      this.form.pageSize = 10;
      this.postAdminOperateGetItemsQueryData(this.form);
    },
  },
};
</script>

<style lang="scss" scoped>
.myform {
  display: flex;
  justify-content: space-between;
  > div {
    display: flex;
  }
  &-item {
    margin-right: 10px;
  }
}
.WorkingSchedule {
  background: #ffff;
  padding: 20px;
  border-radius: 2px;
  @include boxShadow;
  /deep/ .el-table .cell {
    padding: 0 !important;
  }
  /deep/ .el-table--mini td {
    padding: 0 !important;
  }
  /deep/ .el-table--mini th {
    padding: 12px 0 !important;
  }
}
.tableTwo {
  /deep/ .el-table--border {
    border-right: none !important;
  }
}
</style>
